package com.codedancer.campus.client.api.category;

import com.codedancer.campus.client.service.ICategoryService;
import com.codedancer.campus.client.service.vo.category.CategoryVo;
import com.codedancer.campus.common.anno.PassToken;
import com.codedancer.campus.common.core.BaseApi;
import com.codedancer.campus.common.response.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/category")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
    RequestMethod.PUT}, maxAge = 3600)
@Api(value = "分类Api", description = "分类Api", tags = "分类Api")
public class CategoryApi extends BaseApi {

    @Autowired
    private ICategoryService categoryService;

    @GetMapping("/get-by-plate/{plateUuid}")
    @ApiOperation("获取某个板块下的所有分类")
    @PassToken
    public ApiResponse<List<CategoryVo>> getByPlateUuid(@PathVariable(value = "plateUuid",required = true) @ApiParam(value = "板块uuid",required = true) String plateUuid){
        return success(categoryService.getByPlateUuid(plateUuid));
    }
}
